package com.lxx.redisdemo.controller;


import com.lxx.redisdemo.model.User;
import com.lxx.redisdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {


    @Autowired
    private UserService userService;

    @GetMapping("/getUser/{name}")
    public String getUser(@PathVariable( name = "name") String name) {
        User user;

        try {
             user = userService.queryUser(name);
        } catch (Exception e) {
            e.printStackTrace();
            return "查询异常";
        }

        return user.toString();

    }
}
